<div class="page-body">
    <div class="row">
        <div class="widget">
            <div class="widget-header
            <switch name="T_type">
            <case value="1">bg-magenta</case>
            <case value="2">bg-palegreen</case>
            <case value="3">bg-lightred</case>
            <case value="4">bg-blue</case>
            <case value="5">bg-blueberry</case>
            <case value="6">bg-gold</case>
            <default />bg-magenta
            </switch>
                                ">
            <span class="widget-caption">{$T_title|default=CONTROLLER_NAME}</span>
                                <!--Widget Buttons-->
        </div>
            <div class="widget-body">
                <div id="horizontal-form">
                    <form class="form-horizontal form_buy" role="form"
                          action="{:U('doFreeze')}"
                          method="post" enctype="multipart/form-data" onSubmit="return false;">
                        <div class="form-group">
                            <label for="card_id" class="col-sm-3 control-label no-padding-right">会员卡：</label>
                            <div class="col-sm-3">
                                <input type="text" class="form-control" id="card_id" name="card_id" value="" onkeydown="getCard()">

                                <div id="card_info" style="display:none;">
                                    <span class="info"></span><br>
                                    购书折扣：<span class="discount_buy"></span><br>
                                    活动报名费折扣：<span class="discount_apply"></span><br>
                                    借阅可免运费次数：<span class="num_delivery"></span><br>
                                    活动报名费可免次数：<span class="num_activity"></span><br>
                                </div>
                            </div>
                        </div>
                        <hr>
                        <div class="form-group  ">

                            <div class="col-sm-offset-3 col-sm-10">
                                <p class="label label-darkpink graded error_info"></p><br>
                                <input type="button" class="btn btn-danger " value="冻结" onkeypress="freeze()" onclick="freeze()">
                                <input type="button" class="btn btn-primary" value="解冻" onkeypress="unfreeze()" onclick="unfreeze()">
                                <input type="hidden" id="user_id" name="user_id" value="">
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script>

    //    //监听并获取会员卡信息
    //    function getCard(){
    //        var keyCode = null;
    //
    //        if(event.which)
    //            keyCode = event.which;
    //        else if(event.keyCode)
    //            keyCode = event.keyCode;
    //
    //        if(keyCode == 13  ){
    //            getCard_post();
    //        }
    //    }
    //    //获取会员卡信息
    //    function getCard_post(){
    //        var $card_id=$("#card_id").val();
    //        if($.trim($card_id)==""){
    //            $("#card_id").val("");
    //            $("#card_id").focus();
    //            return;
    //        }
    //        $.post("{:U('Card/getinfo')}",{"card_id":$card_id},function(data){
    //            if(data.status=="error"){
    //                $("#card_info .info").html("此卡不存在");
    //                $("#card_info .num_activity").html("");
    //                $("#card_info .num_delivery").html("");
    //                $("#card_info .discount_apply").html("");
    //                $("#card_info .discount_buy").html("");
    //                $("#user_id").val("");
    //                $("#card_info").show();
    //                $("#card_id").focus();
    //            }else{
    //                $("#card_info .info").html("查询成功！");
    //                $("#card_info .num_activity").html(data.data.num_activity);
    //                $("#card_info .num_delivery").html(data.data.num_delivery);
    //                $("#card_info .discount_apply").html(data.data.discount_apply);
    //                $("#card_info .discount_buy").html(data.data.discount_buy);
    //                $("#user_id").val(data.data.user_id);
    //                $("#discount_buy").val(data.data.discount_buy);
    //                $("#card_info").show();
    //                $("#activity_id").focus();
    //            }
    //            cal_all();
    //        },"json");
    //    }

    function cal_all(){

    }
    //获取会员卡成功后回调
    function getsuccess(data) {
        $("#user_id").val(data.data.user_id);
    }
    //提交
    function FSubmit() {
        getCard_post();
        if (!confirm('确认操作?')) {
            return;
        }
        if ($("#user_id").val() == "") {
            $(".error_info").html("请输入有效卡号");
            return;
        }

        $(".form_buy").attr("onSubmit", "");
        $(".form_buy").submit();
        return true;
    }

    function freeze(){
        getCard_post();
        if (!confirm('确认操作?')) {
            return;
        }
        if ($("#user_id").val() == "") {
            $(".error_info").html("请输入有效卡号");
            return;
        }
        var $card_id=$("#card_id").val();
        $.post("{:U('doFreeze')}",{"card_id":$card_id},function(data){
            $(".error_info").html(data.data);
            getCard_post();

        },"json");
    }

    function unfreeze(){
        getCard_post();
        if (!confirm('确认操作?')) {
            return;
        }
        if ($("#user_id").val() == "") {
            $(".error_info").html("请输入有效卡号");
            return;
        }
        var $card_id=$("#card_id").val();
        $.post("{:U('doUnFreeze')}",{"card_id":$card_id},function(data){
            $(".error_info").html(data.data);
            getCard_post();

        },"json");
    }
</script>